package com.yc.spring.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Data
//@AllArgsConstructor // 自动生成带全部属性的构造函数
//@NoArgsConstructor  // 自动生成无参数构造函数
@Component("user4")
public class User {
    private String name;
    private String pwd;
    private int age;
    private List<String> likes;
    // 扩展朋友
    private User friend;
    // 扩展武器
    @Autowired // 自动装配注解
    private Weapon weapon;


    public User(String name, String pwd, int age, List<String> likes) {
        System.out.println("=========1==========");
        this.name = name;
        this.pwd = pwd;
        this.age = age;
        this.likes = likes;
    }

    public User(int age, List<String> likes, String name, String pwd) {
        System.out.println("==========2=========");
        this.name = name + "_name";
        this.pwd = "pwd_"+pwd;
        this.age = age;
        this.likes = likes;
    }

    public User() {
        System.out.println("==========0=========");
    }

    //工程方法(静态)
    public static User build(){
        return new User();
    }
}
